package merisis.util;

import junit.framework.Assert;

public class BitaSetTestUtil {

	public static void printSegmentDetail(BitaSet bss) {

		long[] data = bss.getBitData();
		int numOfSegment = data.length >>> 1;
		for (int i = 0; i < numOfSegment; i++) {

			int pos = i << 1;
			System.out.println(String.format("%05d: %016x >> %016x, ones: %d ",
					i, data[pos], data[pos + 1], BitUtil
							.countOne(data[pos + 1])));
		}
	}

	public static void printStatisticsInfo(BitaSet bss) {

		long[] data = bss.getBitData();
		int numOfSegment = data.length >>> 1;

		long card = bss.cardinality();
		System.out.println(String.format("cardinality: %d, av: %f", card,
				(double) card / numOfSegment));
	}

	public static void scaleSets(BitaSet s, int scale, int[] offsets) {

		long segment = 64 * scale;
		for (int i : offsets) {
			Assert.assertTrue(i < 64);
			s.set(segment + i);
		}
	}

	public static void assertScaleHas(BitaSet s, int scale, int[] offsets) {

		long segment = 64 * scale;
		for (int i : offsets) {
			Assert.assertTrue(i < 64);
			Assert.assertTrue(s.has(segment + i));
		}
	}

	public static void assertScaleHasNot(BitaSet s, int scale,
			int[] offsets) {

		long segment = 64 * scale;
		for (int i : offsets) {
			Assert.assertTrue(i < 64);
			Assert.assertFalse(s.has(segment + i));
		}
	}

}
